<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Basic Form </title>

    <!-- ================= Favicon ================== -->

    <!-- Styles -->
    <link href="__VIS__/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="__VIS__/css/lib/themify-icons.css" rel="stylesheet">
    <link href="__VIS__/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="__VIS__/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="__VIS__/css/lib/unix.css" rel="stylesheet">
    <link href="__VIS__/css/style.css" rel="stylesheet">
    <style>
        .layui-upload-file{
            display: none !important;
        }
    </style>
</head>

<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-8 p-r-0 title-margin-right">
            <div class="page-header">
                <div class="page-title">
                    <h1>添加/编辑系统菜单</h1>
                </div>
            </div>
        </div>
        <!-- /# column -->
        <div class="col-lg-4 p-l-0 title-margin-left">
            <div class="page-header">
                <div class="page-title">
                    <ol class="breadcrumb text-right">
                        <li><a href="#">管理员</a></li>
                        <li><a href="{:url('index')}">管理员列表</a></li>
                        <li class="active">添加/编辑管理员</li>
                    </ol>
                </div>
            </div>
        </div>
        <!-- /# column -->
    </div>
    <!-- /# row -->
    <section id="main-content">
        <div class="row">
            <div class="col-lg-12">
                <div class="card alert">
                    <div class="card-header">
                        <h4>添加/编辑系统菜单</h4>
                        <div class="card-header-right-icon">
                            <ul>
                                <li class="card-close" data-dismiss="alert"><i class="ti-close"></i></li>
                                <li class="doc-link"><a href="#"><i class="ti-link"></i></a></li>
                                <li class="page-refresh"><i class="fa fa-refresh"></i> 刷新页面</li>
                            </ul>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="basic-elements">
                            <form class="vis_form">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="form-group">
                                            <label>分组</label>
                                            <select class="form-control" name="admin_cate_id">
                                                <option>请选择分组</option>
                                                {volist name="info['admin_cate']" id="vo"}
                                                <option value="{$vo.id}" {notempty name="$info.admin.admin_cate_id"}{eq name="$info.admin.admin_cate_id" value="$vo.id"} selected=""{/eq}{/notempty}>{$vo.name}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label>用户名</label>
                                            <input type="text" name="username" class="form-control" placeholder="请输入" {notempty name="$info.admin.username"}value="{$info.admin.username}"{/notempty}>
                                            <span class="help-block">
														<small>菜单排序，0为默认排序，由小到大 </small>
													</span>
                                        </div>
                                        <div class="form-group">
                                            <label>昵称</label>
                                            <input type="text" name="nick" class="form-control" placeholder="请输入" {notempty name="$info.admin.nick"}value="{$info.admin.nick}"{/notempty}>
                                        </div>
                                        <div class="form-group" id="img_thumb">
                                            <label>头像</label>
                                            <input id="thumb" class="btn btn-default btn-outline" style="display: block;margin-bottom: 15px" name="file" value="上传头像" >
                                            <img id="show_img" width="150" height="150" {notempty name="$info.admin.thumb"}src="{$info.admin.thumb|geturl}"{/notempty}>
                                            <span class="help-block">
														<small class="error_img_up"> </small>
													</span>
                                        </div>
                                        <div class="form-group">
                                            <label>邮箱</label>
                                            <input type="email" name="email" class="form-control" placeholder="请输入" {notempty name="$info.admin.email"}value="{$info.admin.email}"{/notempty}>
                                        </div>
                                        {empty name="$info.admin"}
                                        <div class="form-group">
                                            <label>密码</label>
                                            <input type="password" name="password" class="form-control" placeholder="请输入" >
                                        </div>
                                        <div class="form-group">
                                            <label>确认密码</label>
                                            <input type="password" name="password_confirm" class="form-control" placeholder="请输入">
                                        </div>
                                        {/empty}
                                        {notempty name="$info.admin"}
                                        <input type="hidden" name="id" value="{$info.admin.id}">
                                        {/notempty}

                                        <div class="form-group">
                                            <a href="#" class="btn btn-default btn-outline vis_form_btn">立即提交</a>
                                        </div>
                                    </div>

                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /# column -->
            <!-- /# column -->
        </div>
        <!-- /# row -->
    </section>
</div>


<div id="search">
    <button type="button" class="close">×</button>
    <form>
        <input type="search" value="" placeholder="type keyword(s) here" />
        <button type="submit" class="btn btn-primary">Search</button>
    </form>
</div>
<!-- jquery vendor -->
<script src="__VIS__/js/lib/jquery.min.js"></script>
<script src="__VIS__/js/lib/jquery.nanoscroller.min.js"></script>
<!-- nano scroller -->
<script src="__VIS__/js/lib/menubar/sidebar.js"></script>
<script src="__VIS__/js/lib/preloader/pace.min.js"></script>
<!-- sidebar -->
<script src="__VIS__/js/lib/bootstrap.min.js"></script>
<!-- bootstrap -->
<script src="__VIS__/js/layui/layui.js"></script>

<!-- scripit init-->
<script>

    layui.use(['upload','layer'], function(){
        var upload=layui.upload,layer=layui.layer;
        var uploadInst = upload.render({
            elem: '#thumb' //绑定元素
            ,url: "{:url('basic/upload')}" //上传接口
            ,done: function(res){
                //上传完毕回调
                if(res.code == 2) {
                    $('#show_img').attr('src',res.src);
                    $('#img_thumb').append('<input type="hidden" name="thumb" value="'+ res.id +'">');
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error: function(){
                //请求异常回调
                //演示失败状态，并实现重传
                var demoText = $('.error_img_up');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="btn btn-warning demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
        $('.page-refresh').on("click", function() {
            location.reload();
        });
        $('.vis_form_btn').click(function () {
            $.ajax({
                url:"{:url('admin/member/edit')}",
                type:'POST',
                dataType:'JSON',
                data:$('.vis_form').serialize(),
                success:function (res) {
                    if(res.code == 1){
                        layer.msg(res.msg,{icon:6},function () {
                            window.location.href=res.url;
                        })
                    }else {
                        layer.msg(res.msg,{icon:5})
                    }
                }
            })
        })
    })
</script>




</body>

</html>